package org.jeecg.modules.demo.roomapartdistribute.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import org.jeecg.modules.demo.roomapartdistribute.entity.ZnzfCheckApart;
import org.jeecg.modules.demo.roomapartdistribute.entity.ZnzfCheckApartRoomList;
import org.jeecg.modules.demo.roomapartdistribute.mapper.ZnzfCheckApartRoomListMapper;
import org.jeecg.modules.demo.roomapartdistribute.service.IZnzfCheckApartRoomListService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;

import javax.annotation.Resource;
import java.util.List;

/**
 * @Description: 核定单位房源列表
 * @Author: jeecg-boot
 * @Date:   2022-03-22
 * @Version: V1.0
 */
@Service
public class ZnzfCheckApartRoomListServiceImpl extends ServiceImpl<ZnzfCheckApartRoomListMapper, ZnzfCheckApartRoomList> implements IZnzfCheckApartRoomListService {

    @Resource
    private ZnzfCheckApartRoomListMapper znzfCheckApartRoomListMapper;

    @Override
    public List<ZnzfCheckApartRoomList> searchsByZnzfCheckApartId(String zcaId) {
        LambdaQueryWrapper<ZnzfCheckApartRoomList> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.eq(ZnzfCheckApartRoomList::getCheckApart, zcaId);
        return znzfCheckApartRoomListMapper.selectList(queryWrapper);
    }

    @Override
    public List<ZnzfCheckApartRoomList> searchsByRoomId(String roomId) {
        LambdaQueryWrapper<ZnzfCheckApartRoomList> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.eq(ZnzfCheckApartRoomList::getRoomId, roomId);
        return znzfCheckApartRoomListMapper.selectList(queryWrapper);
    }

    @Override
    public ZnzfCheckApartRoomList searchByRoomIdAndCheckApartId(String roomId, String CheckApartId) {
        LambdaQueryWrapper<ZnzfCheckApartRoomList> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.eq(ZnzfCheckApartRoomList::getCheckApart, CheckApartId);
        queryWrapper.eq(ZnzfCheckApartRoomList::getRoomId, roomId);
        return znzfCheckApartRoomListMapper.selectOne(queryWrapper);
    }


    @Override
    public String findRoomByUserId(String userId) {
        LambdaQueryWrapper<ZnzfCheckApartRoomList> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.eq(ZnzfCheckApartRoomList::getUid, userId);
        ZnzfCheckApartRoomList room = znzfCheckApartRoomListMapper.selectOne(queryWrapper);
        return room.getRoomId();
    }
}
